package com.example.exception;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;

import java.util.Properties;

@Configuration
public class GlobalException {

    @Bean
    public SimpleMappingExceptionResolver simpleMappingExceptionResolver() {
        SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver();
        Properties mappings = new Properties();
        mappings.setProperty(ArithmeticException.class.getName(), "error1");
        mappings.setProperty(NullPointerException.class.getName(), "error2");
        resolver.setExceptionMappings(mappings);

        return resolver;
    }

}
